let formValidate = {
  data(){
    let numberValidator = (rule,value,callback) => {
      if(value===0){
        return callback(new Error(this.$t('m.container.sizeValidate1')))
      } else if(value>500){
        return callback(new Error(this.$t('m.container.sizeValidate2')))
      }
      callback()
    }
    let weightValidator = (rule,value,callback) => {
      if(value===0){
        return callback(new Error(this.$t('m.container.weightValidae1')))
      } else if(value>500){
        return callback(new Error(this.$t('m.container.weightValidae2')))
      }
      callback()
    }
    let containertypecodeValidator = (rule,value,callback) => {
      if(!/^[A-Za-z0-9]+$/.test(value)){
        return callback(new Error(this.$t('m.container.containertypecodeValidate')))
      }
      callback()
    }
    return {
      ruleForm:{
        containertypename:[{ required:true, message:this.$t('m.container.containertypenameValidate'), trigger:'blur'}],
        containertypecode:[{ required:true, validator:containertypecodeValidator, trigger:'blur'}],
        type:[{ required:true, message:this.$t('m.container.containertypeValidate'), trigger:'blur'}],
        extent:[{ validator:numberValidator, trigger:'blur' }],
        width:[{ validator:numberValidator, trigger:'blur' }],
        height:[{ validator:numberValidator, trigger:'blur' }],
        maxweight:[{ required:true, validator:weightValidator, trigger:'blur' }]
      }
    }
  }
}
export {
  formValidate
}